package config

import (
	"fmt"
	"github.com/go-redis/redis/v8"
)

type Redis struct {
	Path   string `json:"path" mapstructure:"path" yaml:"path"`
	Port   string `json:"port" mapstructure:"port" yaml:"port"`
	Passwd string `json:"passwd" mapstructure:"passwd" yaml:"passwd"`
	Db     int    `json:"db" mapstructure:"db" yaml:"db"`
}

// redis连接
func (r *Redis) Dsn() *redis.Options {
	return &redis.Options{
		Addr:     fmt.Sprintf("%s:%s", r.Path, r.Port),
		Password: r.Passwd,
		DB:       r.Db,
	}
}
